package com.business_clean.viewmodel.request

import androidx.lifecycle.MutableLiveData
import com.business_clean.app.network.NetUrl
import com.business_clean.data.mode.circle.ChatMessageLIst
import com.business_clean.data.mode.circle.ChatStatEntity
import me.hgj.mvvmhelper.base.BaseViewModel
import me.hgj.mvvmhelper.ext.rxHttpRequest
import me.hgj.mvvmhelper.net.LoadingType
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse

class CircleViewModel : BaseViewModel() {


    var chatMessageList = MutableLiveData<ChatMessageLIst>()
    var chatStat = MutableLiveData<ChatStatEntity>()

    /**
     * 获取列表
     */
    fun requestChatList(hashMap: HashMap<String, String>) {
        rxHttpRequest {
            onRequest = {
                chatMessageList.value = RxHttp.get(NetUrl.GET_CIRCLE_LIST)
                    .addAll(hashMap)
                    .toResponse<ChatMessageLIst>().await()
            }
            loadingType = LoadingType.LOADING_NULL
        }
    }

    /**
     * 获取统计
     */
    fun requestChatStat(stat_date: String) {
        rxHttpRequest {
            onRequest = {
                chatStat.value = RxHttp.get(NetUrl.GET_CIRCLE_STAT)
                    .add("stat_date", stat_date)
                    .toResponse<ChatStatEntity>().await()
            }
            loadingType = LoadingType.LOADING_NULL
        }

    }
}